Imports CIPF.Annotations

Namespace Annotations
  Public Class AnnotationProperties
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
      MyBase.New()

      'This call is required by the Windows Form Designer.
      InitializeComponent()

      'Add any initialization after the InitializeComponent() call
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
        If Not (components Is Nothing) Then
          components.Dispose()
        End If
      End If
      MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents btnOk As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents chkVisible As System.Windows.Forms.CheckBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtText As System.Windows.Forms.TextBox
    Friend WithEvents pnlColor As System.Windows.Forms.Panel
    Friend WithEvents polyColorDialog As System.Windows.Forms.ColorDialog
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents nudPointSize As System.Windows.Forms.NumericUpDown
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents rdComplement As System.Windows.Forms.RadioButton
    Friend WithEvents rdXor As System.Windows.Forms.RadioButton
    Friend WithEvents rdIntersect As System.Windows.Forms.RadioButton
    Friend WithEvents rdUnion As System.Windows.Forms.RadioButton
    Friend WithEvents txtKey As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents nudLineWidth As System.Windows.Forms.NumericUpDown
    Friend WithEvents nudMaximumNrPts As System.Windows.Forms.NumericUpDown
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents chkClosed As System.Windows.Forms.CheckBox
    Friend WithEvents pnlQuickSets As System.Windows.Forms.Panel
    Friend WithEvents rdLine As System.Windows.Forms.RadioButton
    Friend WithEvents rdClosedContour As System.Windows.Forms.RadioButton
    Friend WithEvents rdOpen As System.Windows.Forms.RadioButton
    Friend WithEvents rdText As System.Windows.Forms.RadioButton
    Friend WithEvents rdLoosePoints As System.Windows.Forms.RadioButton
    Friend WithEvents rdCustom As System.Windows.Forms.RadioButton
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents pnlCreation As System.Windows.Forms.GroupBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
      Me.btnCancel = New System.Windows.Forms.Button
      Me.btnOk = New System.Windows.Forms.Button
      Me.Label1 = New System.Windows.Forms.Label
      Me.Label3 = New System.Windows.Forms.Label
      Me.chkVisible = New System.Windows.Forms.CheckBox
      Me.Label2 = New System.Windows.Forms.Label
      Me.txtText = New System.Windows.Forms.TextBox
      Me.polyColorDialog = New System.Windows.Forms.ColorDialog
      Me.pnlColor = New System.Windows.Forms.Panel
      Me.Label4 = New System.Windows.Forms.Label
      Me.nudPointSize = New System.Windows.Forms.NumericUpDown
      Me.Panel1 = New System.Windows.Forms.Panel
      Me.rdComplement = New System.Windows.Forms.RadioButton
      Me.rdXor = New System.Windows.Forms.RadioButton
      Me.rdIntersect = New System.Windows.Forms.RadioButton
      Me.rdUnion = New System.Windows.Forms.RadioButton
      Me.txtKey = New System.Windows.Forms.TextBox
      Me.Label7 = New System.Windows.Forms.Label
      Me.nudLineWidth = New System.Windows.Forms.NumericUpDown
      Me.Label8 = New System.Windows.Forms.Label
      Me.pnlCreation = New System.Windows.Forms.GroupBox
      Me.nudMaximumNrPts = New System.Windows.Forms.NumericUpDown
      Me.Label5 = New System.Windows.Forms.Label
      Me.chkClosed = New System.Windows.Forms.CheckBox
      Me.pnlQuickSets = New System.Windows.Forms.Panel
      Me.rdLine = New System.Windows.Forms.RadioButton
      Me.rdClosedContour = New System.Windows.Forms.RadioButton
      Me.rdOpen = New System.Windows.Forms.RadioButton
      Me.rdText = New System.Windows.Forms.RadioButton
      Me.rdLoosePoints = New System.Windows.Forms.RadioButton
      Me.rdCustom = New System.Windows.Forms.RadioButton
      Me.Label6 = New System.Windows.Forms.Label
      CType(Me.nudPointSize, System.ComponentModel.ISupportInitialize).BeginInit()
      Me.Panel1.SuspendLayout()
      CType(Me.nudLineWidth, System.ComponentModel.ISupportInitialize).BeginInit()
      Me.pnlCreation.SuspendLayout()
      CType(Me.nudMaximumNrPts, System.ComponentModel.ISupportInitialize).BeginInit()
      Me.pnlQuickSets.SuspendLayout()
      Me.SuspendLayout()
      '
      'btnCancel
      '
      Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
      Me.btnCancel.Location = New System.Drawing.Point(218, 368)
      Me.btnCancel.Name = "btnCancel"
      Me.btnCancel.Size = New System.Drawing.Size(64, 25)
      Me.btnCancel.TabIndex = 7
      Me.btnCancel.Text = "Cancel"
      '
      'btnOk
      '
      Me.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK
      Me.btnOk.Location = New System.Drawing.Point(130, 368)
      Me.btnOk.Name = "btnOk"
      Me.btnOk.Size = New System.Drawing.Size(64, 25)
      Me.btnOk.TabIndex = 6
      Me.btnOk.Text = "Ok"
      '
      'Label1
      '
      Me.Label1.Location = New System.Drawing.Point(6, 63)
      Me.Label1.Name = "Label1"
      Me.Label1.Size = New System.Drawing.Size(128, 16)
      Me.Label1.TabIndex = 14
      Me.Label1.Text = "Color"
      '
      'Label3
      '
      Me.Label3.Location = New System.Drawing.Point(7, 92)
      Me.Label3.Name = "Label3"
      Me.Label3.Size = New System.Drawing.Size(62, 16)
      Me.Label3.TabIndex = 16
      Me.Label3.Text = "Text"
      '
      'chkVisible
      '
      Me.chkVisible.CheckAlign = System.Drawing.ContentAlignment.MiddleRight
      Me.chkVisible.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.chkVisible.Location = New System.Drawing.Point(6, 31)
      Me.chkVisible.Name = "chkVisible"
      Me.chkVisible.Size = New System.Drawing.Size(142, 24)
      Me.chkVisible.TabIndex = 21
      Me.chkVisible.Text = "Visible"
      '
      'Label2
      '
      Me.Label2.Location = New System.Drawing.Point(6, 178)
      Me.Label2.Name = "Label2"
      Me.Label2.Size = New System.Drawing.Size(128, 16)
      Me.Label2.TabIndex = 28
      Me.Label2.Text = "Region add"
      '
      'txtText
      '
      Me.txtText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.txtText.Location = New System.Drawing.Point(136, 91)
      Me.txtText.Name = "txtText"
      Me.txtText.Size = New System.Drawing.Size(260, 20)
      Me.txtText.TabIndex = 29
      '
      'polyColorDialog
      '
      Me.polyColorDialog.AnyColor = True
      '
      'pnlColor
      '
      Me.pnlColor.Location = New System.Drawing.Point(136, 59)
      Me.pnlColor.Name = "pnlColor"
      Me.pnlColor.Size = New System.Drawing.Size(22, 21)
      Me.pnlColor.TabIndex = 30
      '
      'Label4
      '
      Me.Label4.Location = New System.Drawing.Point(9, 121)
      Me.Label4.Name = "Label4"
      Me.Label4.Size = New System.Drawing.Size(54, 16)
      Me.Label4.TabIndex = 32
      Me.Label4.Text = "Point size"
      '
      'nudPointSize
      '
      Me.nudPointSize.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.nudPointSize.Location = New System.Drawing.Point(137, 119)
      Me.nudPointSize.Maximum = New Decimal(New Integer() {1024, 0, 0, 0})
      Me.nudPointSize.Name = "nudPointSize"
      Me.nudPointSize.Size = New System.Drawing.Size(55, 20)
      Me.nudPointSize.TabIndex = 33
      Me.nudPointSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
      '
      'Panel1
      '
      Me.Panel1.BackColor = System.Drawing.SystemColors.Window
      Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.Panel1.Controls.Add(Me.rdComplement)
      Me.Panel1.Controls.Add(Me.rdXor)
      Me.Panel1.Controls.Add(Me.rdIntersect)
      Me.Panel1.Controls.Add(Me.rdUnion)
      Me.Panel1.Location = New System.Drawing.Point(137, 171)
      Me.Panel1.Name = "Panel1"
      Me.Panel1.Size = New System.Drawing.Size(261, 33)
      Me.Panel1.TabIndex = 41
      '
      'rdComplement
      '
      Me.rdComplement.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdComplement.Location = New System.Drawing.Point(176, 3)
      Me.rdComplement.Name = "rdComplement"
      Me.rdComplement.Size = New System.Drawing.Size(88, 24)
      Me.rdComplement.TabIndex = 31
      Me.rdComplement.Text = "Complement"
      '
      'rdXor
      '
      Me.rdXor.Checked = True
      Me.rdXor.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdXor.Location = New System.Drawing.Point(136, 3)
      Me.rdXor.Name = "rdXor"
      Me.rdXor.Size = New System.Drawing.Size(48, 24)
      Me.rdXor.TabIndex = 30
      Me.rdXor.TabStop = True
      Me.rdXor.Text = "Xor"
      '
      'rdIntersect
      '
      Me.rdIntersect.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdIntersect.Location = New System.Drawing.Point(64, 3)
      Me.rdIntersect.Name = "rdIntersect"
      Me.rdIntersect.Size = New System.Drawing.Size(72, 24)
      Me.rdIntersect.TabIndex = 29
      Me.rdIntersect.Text = "Intersect"
      '
      'rdUnion
      '
      Me.rdUnion.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdUnion.Location = New System.Drawing.Point(7, 3)
      Me.rdUnion.Name = "rdUnion"
      Me.rdUnion.Size = New System.Drawing.Size(88, 24)
      Me.rdUnion.TabIndex = 28
      Me.rdUnion.Text = "Union"
      '
      'txtKey
      '
      Me.txtKey.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.txtKey.Enabled = False
      Me.txtKey.Location = New System.Drawing.Point(137, 8)
      Me.txtKey.Name = "txtKey"
      Me.txtKey.Size = New System.Drawing.Size(200, 20)
      Me.txtKey.TabIndex = 44
      '
      'Label7
      '
      Me.Label7.Location = New System.Drawing.Point(7, 9)
      Me.Label7.Name = "Label7"
      Me.Label7.Size = New System.Drawing.Size(132, 16)
      Me.Label7.TabIndex = 43
      Me.Label7.Text = "Name"
      '
      'nudLineWidth
      '
      Me.nudLineWidth.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.nudLineWidth.Location = New System.Drawing.Point(137, 147)
      Me.nudLineWidth.Maximum = New Decimal(New Integer() {1024, 0, 0, 0})
      Me.nudLineWidth.Name = "nudLineWidth"
      Me.nudLineWidth.Size = New System.Drawing.Size(55, 20)
      Me.nudLineWidth.TabIndex = 46
      Me.nudLineWidth.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
      '
      'Label8
      '
      Me.Label8.Location = New System.Drawing.Point(9, 150)
      Me.Label8.Name = "Label8"
      Me.Label8.Size = New System.Drawing.Size(66, 16)
      Me.Label8.TabIndex = 45
      Me.Label8.Text = "Line width"
      '
      'pnlCreation
      '
      Me.pnlCreation.Controls.Add(Me.nudMaximumNrPts)
      Me.pnlCreation.Controls.Add(Me.Label5)
      Me.pnlCreation.Controls.Add(Me.chkClosed)
      Me.pnlCreation.Controls.Add(Me.pnlQuickSets)
      Me.pnlCreation.Controls.Add(Me.Label6)
      Me.pnlCreation.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.pnlCreation.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.pnlCreation.Location = New System.Drawing.Point(3, 210)
      Me.pnlCreation.Name = "pnlCreation"
      Me.pnlCreation.Size = New System.Drawing.Size(399, 150)
      Me.pnlCreation.TabIndex = 47
      Me.pnlCreation.TabStop = False
      Me.pnlCreation.Text = "Interactive creation"
      '
      'nudMaximumNrPts
      '
      Me.nudMaximumNrPts.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.nudMaximumNrPts.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.nudMaximumNrPts.Location = New System.Drawing.Point(137, 105)
      Me.nudMaximumNrPts.Maximum = New Decimal(New Integer() {256, 0, 0, 0})
      Me.nudMaximumNrPts.Minimum = New Decimal(New Integer() {1, 0, 0, -2147483648})
      Me.nudMaximumNrPts.Name = "nudMaximumNrPts"
      Me.nudMaximumNrPts.Size = New System.Drawing.Size(55, 20)
      Me.nudMaximumNrPts.TabIndex = 52
      Me.nudMaximumNrPts.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
      Me.nudMaximumNrPts.Value = New Decimal(New Integer() {1, 0, 0, -2147483648})
      '
      'Label5
      '
      Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.Label5.Location = New System.Drawing.Point(6, 105)
      Me.Label5.Name = "Label5"
      Me.Label5.Size = New System.Drawing.Size(126, 29)
      Me.Label5.TabIndex = 51
      Me.Label5.Text = "Maximum number of points"
      '
      'chkClosed
      '
      Me.chkClosed.CheckAlign = System.Drawing.ContentAlignment.MiddleRight
      Me.chkClosed.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.chkClosed.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.chkClosed.Location = New System.Drawing.Point(6, 74)
      Me.chkClosed.Name = "chkClosed"
      Me.chkClosed.Size = New System.Drawing.Size(140, 24)
      Me.chkClosed.TabIndex = 50
      Me.chkClosed.Text = "Close"
      '
      'pnlQuickSets
      '
      Me.pnlQuickSets.BackColor = System.Drawing.SystemColors.Window
      Me.pnlQuickSets.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.pnlQuickSets.Controls.Add(Me.rdLine)
      Me.pnlQuickSets.Controls.Add(Me.rdClosedContour)
      Me.pnlQuickSets.Controls.Add(Me.rdOpen)
      Me.pnlQuickSets.Controls.Add(Me.rdText)
      Me.pnlQuickSets.Controls.Add(Me.rdLoosePoints)
      Me.pnlQuickSets.Controls.Add(Me.rdCustom)
      Me.pnlQuickSets.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.pnlQuickSets.Location = New System.Drawing.Point(135, 16)
      Me.pnlQuickSets.Name = "pnlQuickSets"
      Me.pnlQuickSets.Size = New System.Drawing.Size(257, 53)
      Me.pnlQuickSets.TabIndex = 49
      '
      'rdLine
      '
      Me.rdLine.BackColor = System.Drawing.SystemColors.Window
      Me.rdLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdLine.Location = New System.Drawing.Point(112, 24)
      Me.rdLine.Name = "rdLine"
      Me.rdLine.Size = New System.Drawing.Size(48, 24)
      Me.rdLine.TabIndex = 33
      Me.rdLine.Tag = "3"
      Me.rdLine.Text = "Line"
      Me.rdLine.UseVisualStyleBackColor = False
      '
      'rdClosedContour
      '
      Me.rdClosedContour.BackColor = System.Drawing.SystemColors.Window
      Me.rdClosedContour.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdClosedContour.Location = New System.Drawing.Point(7, 24)
      Me.rdClosedContour.Name = "rdClosedContour"
      Me.rdClosedContour.Size = New System.Drawing.Size(112, 24)
      Me.rdClosedContour.TabIndex = 32
      Me.rdClosedContour.Tag = "3"
      Me.rdClosedContour.Text = "Closed contour"
      Me.rdClosedContour.UseVisualStyleBackColor = False
      '
      'rdOpen
      '
      Me.rdOpen.BackColor = System.Drawing.SystemColors.Window
      Me.rdOpen.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdOpen.Location = New System.Drawing.Point(160, 24)
      Me.rdOpen.Name = "rdOpen"
      Me.rdOpen.Size = New System.Drawing.Size(96, 24)
      Me.rdOpen.TabIndex = 31
      Me.rdOpen.Tag = "4"
      Me.rdOpen.Text = "Open contour"
      Me.rdOpen.UseVisualStyleBackColor = False
      '
      'rdText
      '
      Me.rdText.BackColor = System.Drawing.SystemColors.Window
      Me.rdText.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdText.Location = New System.Drawing.Point(160, 3)
      Me.rdText.Name = "rdText"
      Me.rdText.Size = New System.Drawing.Size(88, 24)
      Me.rdText.TabIndex = 30
      Me.rdText.Tag = "1"
      Me.rdText.Text = "Text"
      Me.rdText.UseVisualStyleBackColor = False
      '
      'rdLoosePoints
      '
      Me.rdLoosePoints.BackColor = System.Drawing.SystemColors.Window
      Me.rdLoosePoints.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdLoosePoints.Location = New System.Drawing.Point(72, 3)
      Me.rdLoosePoints.Name = "rdLoosePoints"
      Me.rdLoosePoints.Size = New System.Drawing.Size(88, 24)
      Me.rdLoosePoints.TabIndex = 29
      Me.rdLoosePoints.Tag = "2"
      Me.rdLoosePoints.Text = "Loose Points"
      Me.rdLoosePoints.UseVisualStyleBackColor = False
      '
      'rdCustom
      '
      Me.rdCustom.BackColor = System.Drawing.SystemColors.Window
      Me.rdCustom.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.rdCustom.Location = New System.Drawing.Point(7, 3)
      Me.rdCustom.Name = "rdCustom"
      Me.rdCustom.Size = New System.Drawing.Size(65, 24)
      Me.rdCustom.TabIndex = 28
      Me.rdCustom.Tag = "0"
      Me.rdCustom.Text = "Custom"
      Me.rdCustom.UseVisualStyleBackColor = False
      '
      'Label6
      '
      Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.Label6.Location = New System.Drawing.Point(6, 24)
      Me.Label6.Name = "Label6"
      Me.Label6.Size = New System.Drawing.Size(128, 16)
      Me.Label6.TabIndex = 48
      Me.Label6.Text = "Quick settings"
      '
      'PolygonProperties
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
      Me.ClientSize = New System.Drawing.Size(403, 404)
      Me.Controls.Add(Me.pnlCreation)
      Me.Controls.Add(Me.nudLineWidth)
      Me.Controls.Add(Me.Label8)
      Me.Controls.Add(Me.txtKey)
      Me.Controls.Add(Me.txtText)
      Me.Controls.Add(Me.Label7)
      Me.Controls.Add(Me.Panel1)
      Me.Controls.Add(Me.nudPointSize)
      Me.Controls.Add(Me.Label4)
      Me.Controls.Add(Me.pnlColor)
      Me.Controls.Add(Me.Label2)
      Me.Controls.Add(Me.chkVisible)
      Me.Controls.Add(Me.Label3)
      Me.Controls.Add(Me.Label1)
      Me.Controls.Add(Me.btnCancel)
      Me.Controls.Add(Me.btnOk)
      Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
      Me.Name = "PolygonProperties"
      Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
      Me.Text = "Annotation properties"
      CType(Me.nudPointSize, System.ComponentModel.ISupportInitialize).EndInit()
      Me.Panel1.ResumeLayout(False)
      CType(Me.nudLineWidth, System.ComponentModel.ISupportInitialize).EndInit()
      Me.pnlCreation.ResumeLayout(False)
      CType(Me.nudMaximumNrPts, System.ComponentModel.ISupportInitialize).EndInit()
      Me.pnlQuickSets.ResumeLayout(False)
      Me.ResumeLayout(False)
      Me.PerformLayout()

    End Sub

#End Region

    Public Sub SetDialogNewProperties(ByVal annContainer As AnnotationContainer)
      pnlColor.BackColor = Color.FromArgb(annContainer.Color.R, annContainer.Color.G, annContainer.Color.B)

      'Closed and maxmum nr of points are only releveant when doing interactive creation
      txtKey.Enabled = True
      Me.pnlCreation.Enabled = True
      Me.rdClosedContour.Checked = True
      SetClosedContour()
    End Sub

    Public Sub SetDialogProperties(ByVal ann As Annotation)
      'Set all the dialog properties using the annotation values

      Select Case ann.AddMode
        Case RegionAddMode.Complement
          rdComplement.Checked = True
        Case RegionAddMode.Intersect
          rdIntersect.Checked = True
        Case RegionAddMode.Union
          rdUnion.Checked = True
        Case RegionAddMode.XorMode
          rdXor.Checked = True
      End Select

      txtKey.Text = ann.Key
      txtText.Text = ann.Text
      chkVisible.Checked = ann.Visible
      pnlColor.BackColor = Color.FromArgb(ann.Color.R, ann.Color.G, ann.Color.B)
      nudPointSize.Value = ann.PointSize
      nudLineWidth.Value = ann.LineWidth

      'Closed and maxmum nr of points are only releveant when doing interactive creation
      chkClosed.Checked = ann.Closed
      nudMaximumNrPts.Value = ann.MaximumNumberOfPointsOnCreation

      txtKey.Enabled = False
      Me.pnlCreation.Enabled = False
    End Sub

    Public Overloads Function SetAnnotationProperties(ByVal container As AnnotationContainer) As Annotation
      'We create a new annotation in given container
      Dim strKey As String
      If txtKey.TextLength > 0 Then
        strKey = txtKey.Text
      Else
        Dim iID As Integer = 1
        Do While container.ContainsKey("Annotation " & iID)
          iID = iID + 1
        Loop
        strKey = "Annotation " & iID
      End If

      Dim poly As New Annotation
      container.Add(strKey, poly)
      SetAnnotationProperties(poly)
      Return poly
    End Function

    Public Overloads Sub SetAnnotationProperties(ByVal ann As Annotation)
      'Set all the properties using the dialog values

      If rdComplement.Checked Then ann.AddMode = RegionAddMode.Complement
      If rdUnion.Checked Then ann.AddMode = RegionAddMode.Union
      If rdIntersect.Checked Then ann.AddMode = RegionAddMode.Intersect
      If rdXor.Checked Then ann.AddMode = RegionAddMode.XorMode

      ann.Color = pnlColor.BackColor
      ann.Text = txtText.Text
      ann.Visible = chkVisible.Checked
      ann.PointSize = CInt(nudPointSize.Value)
      ann.LineWidth = CInt(nudLineWidth.Value)
      ann.MaximumNumberOfPointsOnCreation = CInt(nudMaximumNrPts.Value)
      ann.Closed = chkClosed.Checked
    End Sub

    Private Sub SetClosedContour()
      'Closed contour or AnnotationPoints
      chkVisible.Checked = True
      nudLineWidth.Value = 1
      nudPointSize.Value = 3
      chkClosed.Checked = True
      nudMaximumNrPts.Value = -1
    End Sub

    Private Sub rdClosedContour_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdClosedContour.CheckedChanged
      If rdClosedContour.Checked Then SetClosedContour()
    End Sub

    Private Sub rdLoosePoints_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdLoosePoints.CheckedChanged
      If rdLoosePoints.Checked Then
        'Markers, e.g. for counting objects
        chkVisible.Checked = True
        nudPointSize.Value = 7
        nudLineWidth.Value = 0
        chkClosed.Checked = False
        nudMaximumNrPts.Value = -1
      End If
    End Sub

    Private Sub rdText_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdText.CheckedChanged
      'Text at one location
      chkVisible.Checked = True
      nudPointSize.Value = 3
      nudLineWidth.Value = 0
      chkClosed.Checked = False
      nudMaximumNrPts.Value = 1
    End Sub

    Private Sub rdOpen_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdOpen.CheckedChanged
      'Open contour or polyline
      chkVisible.Checked = True
      nudPointSize.Value = 3
      nudLineWidth.Value = 1
      chkClosed.Checked = False
      nudMaximumNrPts.Value = -1
    End Sub

    Private Sub rdLine_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdLine.CheckedChanged
      'Line
      chkVisible.Checked = True
      nudPointSize.Value = 3
      nudLineWidth.Value = 1
      chkClosed.Checked = False
      nudMaximumNrPts.Value = 2
    End Sub

    Private Sub pnlColor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlColor.Click
      If polyColorDialog.ShowDialog() = DialogResult.OK Then
        pnlColor.BackColor = polyColorDialog.Color
      End If
    End Sub
  End Class
End Namespace
